home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / examples / tcl / x04.tcl < prev    next >
Encoding:
Text File  |  1994-08-09  |  1.4 KB  |  61 lines

  1. # $Id: x04.tcl,v 1.2 1994/08/09 08:23:24 mjl Exp $
  2. # $Log: x04.tcl,v $
  3. # Revision 1.2  1994/08/09  08:23:24  mjl
  4. # Changed to new tclMatrix notation.
  5. #
  6. # Revision 1.1  1994/06/30  18:49:36  mjl
  7. # Tcl demo programs, which fully reproduce their x??c counterpart.
  8. #
  9. #----------------------------------------------------------------------------
  10. # PLplot Tcl demo #4
  11. #
  12. # After sourcing, just type "4".
  13. #----------------------------------------------------------------------------
  14.  
  15. proc 4 {} {
  16.     matrix freql f 101
  17.     matrix ampl f 101
  18.     matrix phase f 101
  19.  
  20.     plssub 1 1
  21.     plbop
  22.     plfont 2
  23.  
  24.     set f0 1000.0
  25.     for {set i 1} {$i <= 100} {incr i} {
  26.     freql $i = [expr 1.0 + $i / 20.0]
  27.     set freq [expr pow(10.0, [freql $i])]
  28.     ampl $i = [expr 20.0 * log10(1.0 / sqrt(1.0 + pow(($freq/$f0), 2)))]
  29.     phase $i = [expr -(180.0 / 3.141592654) * atan($freq/$f0)]
  30.     }
  31.  
  32.     plvpor 0.15 0.85 0.1 0.9
  33.     plwind 1.0 6.0 -80.0 0.0
  34.  
  35.     plcol 1
  36.     plbox "bclnst" 0.0 0 "bnstv" 0.0 0
  37.  
  38.     plcol 2
  39.     plline 101 freql ampl
  40.  
  41.     plcol 1
  42.     plptex 5.0 -30.0 1.0 -20.0 0.5 "-20 dB/decade"
  43.     plwind 1.0 6.0 -100.0 0.0
  44.     plbox "" 0.0 0 "cmstv" 30.0 3
  45.  
  46.     plcol 3
  47.     plline 101 freql phase
  48.  
  49.     plcol 1
  50.     plmtex "b" 3.2 0.5 0.5 "Frequency"
  51.     plmtex "t" 2.0 0.5 0.5 "Single Pole Low-Pass Filter"
  52.  
  53.     plcol 2
  54.     plmtex "l" 5.0 0.5 0.5 "Amplitude (dB)"
  55.  
  56.     plcol 3
  57.     plmtex "r" 5.0 0.5 0.5 "Phase shift (degrees)"
  58.  
  59.     pleop
  60. }
  61.